package com.wiscamp.ninechapters.problems.domain.models.problems.answers;


import com.wiscamp.ninechapters.problems.enums.AnswerTypes;
import com.wiscamp.ninechapters.problems.math.LatexDecimalRange;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 小数范围答案
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class DecimalRangeAnswer extends Answer {
    /**
     * 答案值
     */
    private LatexDecimalRange value;

    public DecimalRangeAnswer(long answerId, long questionId, int answerIndex, int groupIndex, LatexDecimalRange value) {
        setAnswerType(AnswerTypes.INTEGER_RANGE);
        this.value = value;
        setAnswerId(answerId);
        setQuestionId(questionId);
        setAnswerIndex(answerIndex);
        setGroupIndex(groupIndex);
        setAnswerTypeId(this.getAnswerType().getValue());
    }

    @Override
    public String getAnswerText() {
        //this.setContentHypertext(value.getLatex());
        return value.getLatex();
    }

    /*@Override
    public boolean compareAnswer(String contentText) {
        var values = contentText.split("-");
        if (values.length != 2) return false;
        var beginText = values[0];
        var endText = values[1];
        var beginValue = ParseUtils.parseBigDecimal(beginText);
        var endValue = ParseUtils.parseBigDecimal(endText);
        return value.getBegin().compareTo(beginValue) == 0 && value.getEnd().compareTo(endValue) == 0;
    }*/
}
